<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    li{
      height:50px;
      margin-top:5px;
      background: pink;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="addArr">增加</button>
    <ul ref="oul">
      <li v-for="(el,index) in arr" @click="change(index)" :key="index">
        {{el}}
      </li>
    </ul>

  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        arr: [1,2,3,4],
      },
      methods: {
        addArr () {
          this.arr.push(111);
           // this.$refs.oul.children[this.$refs.oul.children.length-1].style.background="red";
          this.$nextTick(()=>{
            // 回调在数据改变，真实dom更新完毕后触发
            this.$refs.oul.children[this.$refs.oul.children.length-1].style.background="red";
          })
        }
      }
    })
  </script>
</body>
</html>